<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <ul>
            <li v-for="item in cars">
                {{item.name}}
                <ul>
                    <li v-for="li in item.type" @click="changeType">{{li}}</li>
                </ul>
            </li>
        </ul>
    </div>
    <script src="./js/vue.js"></script>
    <script>
        new Vue({
            el: '#app',
            data: {
                cars: [
                    {
                        name: '宝马',
                        type: ['宝马325', '宝马525', '宝马730']
                    },

                    {
                        name: '奔驰',
                        type: ['奔驰c200', '奔驰e300', '奔驰s400']
                    }
                ]
            },

            // 使用变异数组的方法也可以使视图更新
            /*
                'push','pop', 'shift', 'unshift', 'reverse', 'splice', 'sort'
            
            */
            methods: {
                changeType() {
                    // this.cars[0].type[0] = '宝马530'
                    console.log(this)
                    this.$set(this.cars[0].type, 0, '宝马530')
                    console.log(this.cars)
                }
            }
        })
    </script>
</body>
</html>